package org.langke.springboot.prometheusmicrometer;

import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.DistributionSummary;
import io.micrometer.core.instrument.MeterRegistry;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PrometheusCustomMonitor {
    @Autowired
    private MeterRegistry registry;
    private Counter orderCount;
    private DistributionSummary amountSum;
    @PostConstruct
    private void init() {
        orderCount = registry.counter("order_request_count", "tag", "order");
        amountSum = registry.summary("order_amount_sum", "tag", "orderAmount");
    }
    public Counter getOrderCount() {
        return orderCount;
    }

    public DistributionSummary getAmountSum() {
        return amountSum;
    }
}
